package com.dwxt.parabolic.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.Page;
import com.dwxt.parabolic.entity.User;
import com.dwxt.parabolic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/parabolic/user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 为公司（小区）或安装公司添加管理用户
     *
     * @param user
     * @return
     */
    @RequestMapping("/add")
    public BaseResult addCompanyUser(User user) {
        return userService.addCompanyUser(user);
    }

    /**
     * 条件查询用户
     */
    @RequestMapping("/list")
    public BaseResult getUserList(User user, Page page) {
        return userService.getUserList(user, page);
    }

    /**
     * 修改用户
     */
    @RequestMapping("/update")
    public BaseResult update(User user) {
        return userService.update(user);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public BaseResult delete(String id){
        return userService.delete(id);
    }

    /**
     * 用户登录
     */
    @RequestMapping("/login")
    public BaseResult login(User user) {
        return userService.login(user.getPhoneNumber(), user.getPassword());
    }

    /**
     * 查询当前登录公司的所有用户
     */
    @RequestMapping("/list/current")
    public BaseResult getCurrentUserList() {
        return userService.getCurrentUserList();
    }

    /**
     * 查询现登录的用户
     */
    @RequestMapping("/current")
    public BaseResult selectCurrentLoginUser(){
        return userService.selectCurrentLoginUser();
    }





}
